package com.example.rjb_shoping.service.impl;

import com.example.rjb_shoping.entity.RjbFavorite;
import com.example.rjb_shoping.dao.RjbFavoriteDao;
import com.example.rjb_shoping.service.RjbFavoriteService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (RjbFavorite)表服务实现类
 *
 * @author makejava
 * @since 2021-08-07 16:24:25
 */
@Service("rjbFavoriteService")
public class RjbFavoriteServiceImpl implements RjbFavoriteService {
    @Resource
    private RjbFavoriteDao rjbFavoriteDao;

    /**
     * 通过ID查询单条数据
     *
     * @param fId 主键
     * @return 实例对象
     */
    @Override
    public RjbFavorite queryById(Integer fId) {
        return this.rjbFavoriteDao.queryById(fId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<RjbFavorite> queryAllByLimit(int offset, int limit) {
        return this.rjbFavoriteDao.queryAllByLimit(offset, limit);
    }

    @Override
    public int insert(RjbFavorite rjbFavorite) {
        return this.rjbFavoriteDao.insert(rjbFavorite);
    }


    /**
     * 修改数据
     *
     * @param rjbFavorite 实例对象
     * @return 实例对象
     */
    @Override
    public RjbFavorite update(RjbFavorite rjbFavorite) {
        this.rjbFavoriteDao.update(rjbFavorite);
        return this.queryById(rjbFavorite.getFId());
    }

    /**
     * 通过主键删除数据
     *
     * @param fId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer fId) {
        return this.rjbFavoriteDao.deleteById(fId) > 0;
    }

    @Override
    public List<RjbFavorite> selectByCid(Integer cid) {
        return this.rjbFavoriteDao.selectByCid(cid);
    }

    @Override
    public RjbFavorite selectcF(Integer cid, Integer mid) {
        return this.rjbFavoriteDao.selectcF(cid,mid);
    }
}
